package com.zzz.friend.controller.user;

import com.zzz.common.core.constants.HttpConstants;
import com.zzz.common.core.controller.BaseController;
import com.zzz.common.core.domain.R;
import com.zzz.common.core.domain.TableDataInfo;
import com.zzz.friend.domain.exam.dto.ExamDTO;
import com.zzz.friend.domain.exam.dto.ExamQueryDTO;
import com.zzz.friend.service.user.UserExamService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: oj-project
 * @BelongsPackage: com.zzz.friend.controller.exam
 * @Author: zhai
 * @CreateTime: 2025-11-02  18:50
 * @Description: TODO
 * @Version: 1.0
 */
@Tag(name = "用户竞赛端")
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {

    @Autowired
    private UserExamService userExamService;

    @PostMapping("/enter")
    @Operation(summary = "报名竞赛", description = "报名竞赛")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @Validated @RequestBody ExamDTO examDTO) {
        return toR(userExamService.enter(token, examDTO.getExamId()));
    }

    @GetMapping("/list")
    @Operation(summary = "获取用户报名的竞赛列表", description = "获取用户报名的竞赛列表")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return userExamService.list(examQueryDTO);
    }
}
